from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time
driver = webdriver.Chrome()
driver.get("https://www.baidu.com/")
driver.maximize_window()
driver.implicitly_wait(15)

# 设置
id = driver.find_element(By.ID,"s-usersetting-top")

# 将鼠标悬浮在设置上
ActionChains(driver).move_to_element(id).perform()
"""
ActionChains：鼠标操作事件
driver：形参
move_to_element：移动到这个元素上
perform：执行这个操作
"""

# 点击 搜索设置
time.sleep(3)
driver.find_elements(By.CLASS_NAME,"set")[0].click()

# 点击保存设置
time.sleep(3)
driver.find_element(By.CLASS_NAME,"prefpanelgo").click()

# 点击弹窗中的确定
time.sleep(3)
alert = driver.switch_to.alert
alert.accept()

# 对弹窗进行取消操作
# alert.dismiss()




